package com.archstoday.activity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ListView;
import android.widget.TextView;

import com.archstoday.R;
import com.archstoday.adapter.UserSendAdapter;
import com.base.utils.ImageUtil;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * 用户信息页面
 */
public class UserInfoActivity extends AsScrollBaseActivity {

    private TextView mTitleTv;
    private CircleImageView mHeadIcon;
    private TextView mNameTv, mFollowTitleTv, mFollowNumTv,
            mCollectTitleTv, mCollectNumTv, mAddressTv, mAgeTv,
            mSexTv, mFollowBtn, mSendTitleTv;
    private ListView mSendList;

    private UserSendAdapter mAdapter;

    private boolean isMe;

    @Override
    protected void initView(Bundle bundle) {
        setContentView(R.layout.activity_user_info);
        mTitleTv = (TextView) findViewById(R.id.title_tv);
        mHeadIcon = (CircleImageView) findViewById(R.id.user_head_icon);
        mNameTv = (TextView) findViewById(R.id.user_name_tv);
        mFollowTitleTv = (TextView) findViewById(R.id.user_follow_title_tv);
        mFollowNumTv = (TextView) findViewById(R.id.user_follow_num_tv);
        mCollectTitleTv = (TextView) findViewById(R.id.user_collection_title_tv);
        mCollectNumTv = (TextView) findViewById(R.id.user_collection_num_tv);
        mAddressTv = (TextView) findViewById(R.id.user_address_tv);
        mAgeTv = (TextView) findViewById(R.id.user_age_tv);
        mSexTv = (TextView) findViewById(R.id.user_sex_tv);
        mFollowBtn = (TextView) findViewById(R.id.user_follow_btn);
        mSendTitleTv = (TextView) findViewById(R.id.user_send_title_tv);
        mSendList = (ListView) findViewById(R.id.user_send_list);
    }

    @Override
    protected void initData(Bundle bundle) {
        getIntent().getIntExtra("userId", 0);
        isMe = getIntent().getBooleanExtra("isMe", false);
        if (!isMe) {
            mTitleTv.setText(R.string.user_info_title_other);
            mFollowTitleTv.setText(R.string.user_info_follow_other);
            mCollectTitleTv.setText(R.string.user_info_collection_other);
            mSendTitleTv.setText(R.string.user_info_send_other);
        } else {
            mTitleTv.setText(R.string.user_info_title_my);
            mFollowTitleTv.setText(R.string.user_info_follow_my);
            mCollectTitleTv.setText(R.string.user_info_collection_my);
            mSendTitleTv.setText(R.string.user_info_send_my);

            mFollowBtn.setText(R.string.user_info_edit_btn);
            mFollowBtn.setTextColor(ImageUtil.getColor(mContext, R.color.green_text));
            mFollowBtn.setBackgroundResource(R.drawable.item_state_bg_green);
        }

        mNameTv.setText("用户名");
        mFollowNumTv.setText("210");
        mCollectNumTv.setText("120");
        mAddressTv.setText("上海");
        mAgeTv.setText("22岁");
        mSexTv.setText("男");

        mAdapter = new UserSendAdapter(mContext);
        mSendList.setAdapter(mAdapter);
        mAdapter.notifyDataSetChanged();
    }

    @Override
    protected void initListener() {
        setOnClickListener(R.id.back_btn);
        setOnClickListener(R.id.user_follow_btn);
    }

    @Override
    public void treatClickEvent(int id) {
        Intent intent;
        switch (id) {
            case R.id.back_btn:
                appFinish();
                break;
            case R.id.user_follow_btn:
                if (!isMe) {

                } else {
                    intent = new Intent(mContext, EditUserActivity.class);
                    startActivity(intent);
                }
                break;
        }
    }
}